package demo2;



/*    public String name;
    private int age2;
    public static String classes = "class::5";

    *//**
     * 实例内部类
     * 1.不能定义静态的属性或方法
     * 2.实例内部当中 包含了外部类的this
     * 3.获取实例内部类的对象
     * 4.生成字节码文件:外部类$内部类
     *//*
    class Teacher{
        public String name;
        private int age;
        //public static int wegiht; //错误
        public static final int weight = 6;//必须初始化，因为是常量
        public Teacher(){
            System.out.println(Student.this.name);
        }
        public void fun(){
            System.out.println(Student.classes);
            System.out.println(this.name);
        }

    }*/
/*static class InsideClass{
    public int data3;
    private int data4;
    static String str2 = "内部类变量";
    public OutClass outClass;
    public InsideClass(OutClass outClass){
        this.outClass = outClass;
        System.out.println("内部类的构造方法!");
    }
    public void fun(){
        System.out.println("内部类的方法!");
    }
}*/
class OutClass{
    public int data1;
    private int data2;
    static String str1 = "外部类变量";
    public OutClass(){
        System.out.println("外部类的构造方法!");
    }
    public void fun(){
        System.out.println("外部类的方法!");
        class A{
            public int date3;
            public void fun(){
                System.out.println("局部内部类，定义在方法里面，几乎用不上");
            }
        }
        A a = new A();
        a.fun();
    }
}
public class Test {
    public static void main(String[] args){
        new OutClass().fun();//匿名对象，只能用一次
    }
}
